﻿'use strict';

/* Controllers */
// signin controller
app.controller('SigninFormController', ['$interval','$rootScope','$scope', '$http', '$state', 'userService', '$cookieStore', function ($interval,$rootScope,$scope, $http, $state, userService, $cookieStore) {
    $cookieStore.remove("zdxtToken");
    $interval.cancel($rootScope.timeMethod);
    $scope.user = {};
    $scope.authError = null;
    $scope.login = function () {
        $scope.authError = null;
        userService.onLoad(serverURL + "/user?code=" + $scope.user.code + "&pwd=" + $scope.user.password).success(function (data, header, config, status) {
            if (data) {
                $state.go('app.resindex');
            } else {
                angular.alert('登陆失败');
            }
        }).error(function (data, header, config, status) {
            angular.alert('登陆失败');
        });
    };
}]);

//app.controller('SigninFormController', ['$scope', '$http', '$state', 'userService', '$cookieStore', function ($scope, $http, $state, userService, $cookieStore) {
//    $cookieStore.remove("zdxtToken");
//    $scope.user = {};
//    $scope.authError = null;
//    $scope.login = function () {
//        $scope.authError = null;
//        var postMessage={username:$scope.user.cod,userpwd: $scope.user.password}
//        userService.onLoad(serverURL + "/user", postMessage).success(function (data, header, config, status) {
//            if (data) {
//                $state.go('app.dictsystem');
//            } else {
//                angular.alert('登陆失败');
//            }
//        }).error(function (data, header, config, status) {
//            angular.alert('登陆失败');
//        });
//    };
//}]);